import request from '@/config/axios'

// OA 补卡申请 VO
export interface ReissueCardApplyVO {
  id: number // 序号
  userId: number // 申请人的用户编号
  reissueDate: Date // 补卡日期
  reissueType: number // 补卡类型
  reason: string // 补卡原因
  appendix: string // 附件
  status: number // 审批结果
  processInstanceId: string // 流程实例的编号
}

// OA 补卡申请 API
export const ReissueCardApplyApi = {
  // 查询OA 补卡申请分页
  getReissueCardApplyPage: async (params: any) => {
    return await request.get({ url: `/oa/reissue-card-apply/page`, params })
  },

  // 查询OA 补卡申请详情
  getReissueCardApply: async (id: number) => {
    return await request.get({ url: `/oa/reissue-card-apply/get?id=` + id })
  },

  // 新增OA 补卡申请
  createReissueCardApply: async (data: ReissueCardApplyVO) => {
    return await request.post({ url: `/oa/reissue-card-apply/create`, data })
  },

  // 修改OA 补卡申请
  updateReissueCardApply: async (data: ReissueCardApplyVO) => {
    return await request.put({ url: `/oa/reissue-card-apply/update`, data })
  },

  // 删除OA 补卡申请
  deleteReissueCardApply: async (id: number) => {
    return await request.delete({ url: `/oa/reissue-card-apply/delete?id=` + id })
  },

  // 导出OA 补卡申请 Excel
  exportReissueCardApply: async (params) => {
    return await request.download({ url: `/oa/reissue-card-apply/export-excel`, params })
  },

  // 统计指定用户本年度每月审核通过的补卡申请数量
  getMonthlyApprovedCountByUser: async (userId: number, year: number) => {
    return await request.get({ url: `/oa/reissue-card-apply/monthly-statistics`, params: { userId, year } })
  },
}
